<html>
<head><meta charset="utf-8"><title>Unsafe blocks in unsafe fns · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Unsafe.20blocks.20in.20unsafe.20fns.html">Unsafe blocks in unsafe fns</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202868023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Unsafe%20blocks%20in%20unsafe%20fns/near/202868023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Ram <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Unsafe.20blocks.20in.20unsafe.20fns.html#202868023">(Jul 04 2020 at 10:44)</a>:</h4>
<p>There are some instances such as <a href="https://github.com/rust-lang/rust/blob/master/src/libstd/io/mod.rs#L628">here</a> that are unsafe functions that don't contain any unsafe operations. Can these be left untouched or is some sort of comment/explanation required?<br>
Removing the unsafe signature would cause incompatible type issues for files that use these functions. Related to <a href="https://github.com/rust-lang/rust/issues/73904">#73904</a>.</p>



<a name="203684294"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Unsafe%20blocks%20in%20unsafe%20fns/near/203684294" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Unsafe.20blocks.20in.20unsafe.20fns.html#203684294">(Jul 13 2020 at 07:18)</a>:</h4>
<p>If the function could truly be safe but is unsafe just because it is part of a trait, IMO it can be left untouched. to avoid confusion it could be useful to add a comment explaining the situation.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>